<?php

use App\Http\Controllers\AboutController;
use App\Http\Controllers\Admin\LoginController;
use App\Http\Controllers\AuthController;
use App\Http\Controllers\BannerController;
use App\Http\Controllers\CaseCategoryController;
use App\Http\Controllers\CasesController;
use App\Http\Controllers\ConfigsController;
use App\Http\Controllers\HonorController;
use App\Http\Controllers\NavbarController;
use App\Http\Controllers\NewsController;
use App\Http\Controllers\NewsCategoryController;
use App\Http\Controllers\PartnerController;
use App\Http\Controllers\ProductCategoryController;
use App\Http\Controllers\ProductController;
use App\Http\Controllers\ServiceController;
use App\Http\Controllers\UploadController;
use App\Http\Controllers\UserController;
use App\Http\Controllers\VideoController;
use Illuminate\Support\Facades\Route;

use App\Http\Controllers\Web\CompanyController;
use App\Http\Controllers\Web\SearchController as WebSearchController;
use App\Http\Controllers\Web\CategoryController as WebCategoryController;
use App\Http\Controllers\Web\CasesController as WebCasesController;
use App\Http\Controllers\Web\ServiceController as WebServiceController;
use App\Http\Controllers\Web\ProductController as WebProductController;
use App\Http\Controllers\Web\PartnerController as WebPartnerController;
use App\Http\Controllers\Web\NewsController as WebNewsController;
use App\Http\Controllers\Web\VideoController as WebVideoController;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function () {
    return redirect('/admin/index.html');
});

Route::post('login', [AuthController::class, 'login']);
Route::post('register', [AuthController::class, 'register']);
Route::post('logout', [AuthController::class, 'logout']);

Route::get('banner', [BannerController::class, 'index']);

Route::get('category/product', [WebCategoryController::class, 'product']);
Route::get('category/cases', [WebCategoryController::class, 'cases']);
Route::get('category/news', [WebCategoryController::class, 'news']);

Route::apiResource('cases', WebCasesController::class)->only(['index', 'show']);
Route::get('partner', [WebPartnerController::class, 'index']);

Route::apiResource('product', WebProductController::class)->only(['index', 'show']);
Route::apiResource('user', UserController::class);
Route::apiResource('service', WebServiceController::class)->only(['index', 'show']);
Route::apiResource('news', WebNewsController::class)->only(['index', 'show']);
Route::apiResource('video', WebVideoController::class)->only(['index', 'show']);
Route::get('configs', [CompanyController::class, 'configs']);
Route::get('search', WebSearchController::class);
Route::get('company/profile', [CompanyController::class, 'profile']);
Route::get('company/sounds', [CompanyController::class, 'sounds']);
Route::get('company/honor', [CompanyController::class, 'honor']);

Route::prefix('api')->group(function () {
    /** admin */
    Route::post('admin/login', [LoginController::class, 'login'])
        ->name('admin.login');
    Route::prefix('admin')->middleware(['auth:sanctum'])->group(function () {
        Route::get('current', [LoginController::class, 'show']);
        Route::put('current', [LoginController::class, 'update']);

        Route::post('upload', [UploadController::class, 'upload']);
        Route::post('logout', [LoginController::class, 'logout'])->name('admin.logout');

        Route::apiResource('banner', BannerController::class);
        Route::delete('banner', [BannerController::class, 'deleteMany']);
        Route::apiResource('navbar', NavbarController::class);
        Route::delete('navbar', [NavbarController::class, 'deleteMany']);

        Route::apiResource('user', UserController::class);

        Route::apiResource('services', ServiceController::class);
        Route::delete('services', [ServiceController::class, 'deleteMany']);

        Route::apiResource('cases_category', CaseCategoryController::class);
        Route::delete('cases_category', [CaseCategoryController::class, 'deleteMany']);

        Route::apiResource('cases', CasesController::class);
        Route::delete('cases', [CasesController::class, 'deleteMany']);

        Route::apiResource('news', NewsController::class);
        Route::delete('news', [NewsController::class, 'deleteMany']);
        Route::apiResource('news_category', NewsCategoryController::class);
        Route::delete('news_category', [NewsCategoryController::class, 'deleteMany']);


        Route::apiResource('partner', PartnerController::class);
        Route::delete('partner', [PartnerController::class, 'deleteMany']);

        Route::apiResource('honor', HonorController::class);
        Route::delete('honor', [HonorController::class, 'deleteMany']);

        Route::apiResource('video', VideoController::class);
        Route::delete('video', [VideoController::class, 'deleteMany']);


        Route::apiResource('product_category', ProductCategoryController::class);
        Route::delete('product_category', [ProductCategoryController::class, 'deleteMany']);
        Route::apiResource('product', ProductController::class);
        Route::delete('product', [ProductController::class, 'deleteMany']);

        Route::get('configs', [ConfigsController::class, 'index']);
        Route::put('configs', [ConfigsController::class, 'update']);

        Route::apiResource('about', AboutController::class);
    });
});
